Click here for interactive plots:

https://kforthman.shinyapps.io/COVID19_Interactive_Plots/

Click here to see how cities and counties overlap:

https://kforthman.shinyapps.io/500citiescounties

Compare COVID stats to Neighborhood Factors

data.cor <- cor(county.Demo_and_Covid.allcounties[,-1], use = "complete.obs", method = "spearman")
corrplot.mixed(data.cor, upper = 'ellipse', lower = 'number', tl.pos = 'lt', tl.cex = 1, lower.col = "black", number.cex = 0.5)

Compare COVID stats to 500 cities data and Neighborhood Factors

data.cor2 <- cor(county.Demo_and_Covid.500counties[,-c(1:2)], use = "complete.obs", method = "spearman")
corrplot.mixed(data.cor2, upper = 'ellipse', lower = 'number', tl.pos = 'lt', tl.cex = 1, lower.col = "black", number.cex = 0.5)

corrplot.mixed(data.cor2[7:13,c(1:5, 14:42,6)], upper = 'ellipse', tl.pos = 'lt', tl.cex = 1, lower.col = "black", number.cex = 0.5)

—-Linear Mixed Effects Model —-

this.lme <- lmer("total.cases.percap ~ Affluence + Singletons.in.Tract + Seniors.in.Tract + African.Americans.in.Tract + Noncitizens.in.Tract + High.BP + Binge.Drinking + Cancer + Asthma + Heart.Disease + COPD + Smoking + Diabetes + No.Physical.Activity + Obesity + Poor.Sleeping.Habits + Poor.Mental.Health + Testing_Rate + Hospitalization_Rate + (1 | stateID)", data = county.Demo_and_Covid.500counties)
## Warning: Some predictor variables are on very different scales: consider
## rescaling

## Warning: Some predictor variables are on very different scales: consider
## rescaling
print(summary(this.lme), correlation=TRUE)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## "total.cases.percap ~ Affluence + Singletons.in.Tract + Seniors.in.Tract + African.Americans.in.Tract + Noncitizens.in.Tract + High.BP + Binge.Drinking + Cancer + Asthma + Heart.Disease + COPD + Smoking + Diabetes + No.Physical.Activity + Obesity + Poor.Sleeping.Habits + Poor.Mental.Health + Testing_Rate + Hospitalization_Rate + (1 | stateID)"
##    Data: county.Demo_and_Covid.500counties
## 
## REML criterion at convergence: -1275.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.2790 -0.3614 -0.0339  0.2674  5.8004 
## 
## Random effects:
##  Groups   Name        Variance    Std.Dev.
##  stateID  (Intercept) 0.000006065 0.002463
##  Residual             0.000015258 0.003906
## Number of obs: 192, groups:  stateID, 35
## 
## Fixed effects:
##                                  Estimate     Std. Error             df
## (Intercept)                 -0.0109765532   0.0115715114  97.6903819289
## Affluence                    0.0048095554   0.0011705323 143.7992133031
## Singletons.in.Tract          0.0009412310   0.0009952295 171.9769598816
## Seniors.in.Tract             0.0005462133   0.0012941986 171.8309587391
## African.Americans.in.Tract   0.0011788070   0.0011019899 171.9265377515
## Noncitizens.in.Tract         0.0016505217   0.0008474492 151.9803456619
## High.BP                      0.0000243144   0.0002100837 156.2592610355
## Binge.Drinking               0.0003568737   0.0002011089  73.2495854494
## Cancer                      -0.0020410923   0.0012606066 147.4497132599
## Asthma                       0.0001281358   0.0006741862  76.2272780433
## Heart.Disease                0.0029349595   0.0015715446 122.9205595997
## COPD                        -0.0001941966   0.0012914724 119.4364440967
## Smoking                     -0.0002021622   0.0002613378 137.9893454612
## Diabetes                    -0.0008515503   0.0006359366 124.8726079012
## No.Physical.Activity         0.0000580965   0.0002404181 134.1139063008
## Obesity                      0.0003620240   0.0002008568 163.2919348647
## Poor.Sleeping.Habits         0.0000868556   0.0001822556 159.8740163594
## Poor.Mental.Health          -0.0000854682   0.0005510922  50.2537009475
## Testing_Rate                 0.0000007758   0.0000002941  44.8632111411
## Hospitalization_Rate        -0.0001228694   0.0001196445  31.8346475230
##                            t value  Pr(>|t|)    
## (Intercept)                 -0.949    0.3452    
## Affluence                    4.109 0.0000665 ***
## Singletons.in.Tract          0.946    0.3456    
## Seniors.in.Tract             0.422    0.6735    
## African.Americans.in.Tract   1.070    0.2863    
## Noncitizens.in.Tract         1.948    0.0533 .  
## High.BP                      0.116    0.9080    
## Binge.Drinking               1.775    0.0801 .  
## Cancer                      -1.619    0.1076    
## Asthma                       0.190    0.8498    
## Heart.Disease                1.868    0.0642 .  
## COPD                        -0.150    0.8807    
## Smoking                     -0.774    0.4405    
## Diabetes                    -1.339    0.1830    
## No.Physical.Activity         0.242    0.8094    
## Obesity                      1.802    0.0733 .  
## Poor.Sleeping.Habits         0.477    0.6343    
## Poor.Mental.Health          -0.155    0.8774    
## Testing_Rate                 2.638    0.0114 *  
## Hospitalization_Rate        -1.027    0.3122    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of fixed effects could have been required in summary()
## 
## Correlation of Fixed Effects:
##             (Intr) Afflnc Sng..T Snr..T A.A..T Nnc..T Hgh.BP Bng.Dr Cancer
## Affluence    0.016                                                        
## Sngltns.n.T  0.020  0.069                                                 
## Snrs.n.Trct  0.474  0.345  0.189                                          
## Afrcn.Am..T  0.123  0.148 -0.387  0.149                                   
## Nnctzns.n.T  0.001  0.117  0.036  0.086 -0.127                            
## High.BP     -0.075  0.260  0.019  0.073 -0.065  0.342                     
## Bing.Drnkng -0.392 -0.124 -0.277 -0.117  0.065 -0.018  0.129              
## Cancer      -0.554 -0.106  0.211 -0.251 -0.076 -0.085 -0.335 -0.051       
## Asthma      -0.409 -0.109 -0.265 -0.215  0.077  0.096  0.111  0.036  0.041
## Heart.Dises -0.179  0.059 -0.309 -0.175  0.250 -0.133  0.056  0.065 -0.490
## COPD         0.573  0.011  0.160  0.265 -0.045  0.244  0.071  0.028 -0.257
## Smoking     -0.095  0.118 -0.177 -0.119 -0.045  0.069 -0.033 -0.278  0.080
## Diabetes     0.146 -0.378 -0.091 -0.193 -0.303 -0.234 -0.553  0.042  0.241
## N.Physcl.Ac -0.208  0.062  0.111  0.014 -0.018 -0.222 -0.013  0.117  0.443
## Obesity     -0.024  0.381  0.477  0.284  0.104  0.162 -0.099 -0.188  0.114
## Pr.Slpng.Hb -0.409 -0.395  0.111 -0.326 -0.278 -0.071 -0.186  0.110  0.098
## Pr.Mntl.Hlt -0.366  0.222 -0.053 -0.028  0.072 -0.122  0.024  0.122  0.352
## Testing_Rat  0.216 -0.112  0.024  0.026  0.012 -0.015 -0.024 -0.073 -0.180
## Hsptlztn_Rt -0.111 -0.128 -0.052 -0.164 -0.052 -0.077 -0.041 -0.081 -0.074
##             Asthma Hrt.Ds COPD   Smokng Diabts N.Ph.A Obesty Pr.S.H Pr.M.H
## Affluence                                                                 
## Sngltns.n.T                                                               
## Snrs.n.Trct                                                               
## Afrcn.Am..T                                                               
## Nnctzns.n.T                                                               
## High.BP                                                                   
## Bing.Drnkng                                                               
## Cancer                                                                    
## Asthma                                                                    
## Heart.Dises  0.321                                                        
## COPD        -0.403 -0.578                                                 
## Smoking      0.105  0.174 -0.464                                          
## Diabetes    -0.133 -0.357  0.001  0.211                                   
## N.Physcl.Ac  0.057 -0.355 -0.005 -0.291 -0.155                            
## Obesity     -0.212 -0.087  0.150 -0.251 -0.371 -0.004                     
## Pr.Slpng.Hb  0.091  0.256 -0.161 -0.082 -0.032 -0.155 -0.140              
## Pr.Mntl.Hlt -0.256  0.073 -0.454  0.022 -0.006  0.002  0.021 -0.124       
## Testing_Rat -0.282 -0.069  0.229  0.107  0.113 -0.276  0.092 -0.140 -0.151
## Hsptlztn_Rt  0.044  0.156 -0.104  0.060 -0.023 -0.005  0.014  0.005 -0.095
##             Tstn_R
## Affluence         
## Sngltns.n.T       
## Snrs.n.Trct       
## Afrcn.Am..T       
## Nnctzns.n.T       
## High.BP           
## Bing.Drnkng       
## Cancer            
## Asthma            
## Heart.Dises       
## COPD              
## Smoking           
## Diabetes          
## N.Physcl.Ac       
## Obesity           
## Pr.Slpng.Hb       
## Pr.Mntl.Hlt       
## Testing_Rat       
## Hsptlztn_Rt  0.080
## fit warnings:
## Some predictor variables are on very different scales: consider rescaling
this.lme <- lmer("total.cases.percap ~ Affluence + Singletons.in.Tract + Seniors.in.Tract + African.Americans.in.Tract + Noncitizens.in.Tract + High.BP + Binge.Drinking + Cancer + Asthma + Heart.Disease + COPD + Smoking + Diabetes + No.Physical.Activity + Obesity + Poor.Sleeping.Habits + Poor.Mental.Health + (1 | stateID)", data = county.Demo_and_Covid.500counties)

print(summary(this.lme), correlation=TRUE)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## "total.cases.percap ~ Affluence + Singletons.in.Tract + Seniors.in.Tract + African.Americans.in.Tract + Noncitizens.in.Tract + High.BP + Binge.Drinking + Cancer + Asthma + Heart.Disease + COPD + Smoking + Diabetes + No.Physical.Activity + Obesity + Poor.Sleeping.Habits + Poor.Mental.Health + (1 | stateID)"
##    Data: county.Demo_and_Covid.500counties
## 
## REML criterion at convergence: -2430.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.8229 -0.3814 -0.0831  0.2771  6.5344 
## 
## Random effects:
##  Groups   Name        Variance    Std.Dev.
##  stateID  (Intercept) 0.000007907 0.002812
##  Residual             0.000013141 0.003625
## Number of obs: 326, groups:  stateID, 51
## 
## Fixed effects:
##                                Estimate   Std. Error           df t value
## (Intercept)                 -0.02386140   0.00814185 192.82505213  -2.931
## Affluence                    0.00303196   0.00073929 302.30000979   4.101
## Singletons.in.Tract          0.00075001   0.00069032 301.05282345   1.086
## Seniors.in.Tract             0.00024369   0.00087192 304.53300753   0.279
## African.Americans.in.Tract   0.00189729   0.00084280 306.81511704   2.251
## Noncitizens.in.Tract         0.00189289   0.00067987 271.72253115   2.784
## High.BP                     -0.00003031   0.00015255 298.75507418  -0.199
## Binge.Drinking               0.00040322   0.00016028 159.16744196   2.516
## Cancer                      -0.00029088   0.00089473 266.41391805  -0.325
## Asthma                       0.00084505   0.00053125 141.53434244   1.591
## Heart.Disease                0.00317138   0.00114784 211.05409998   2.763
## COPD                        -0.00133304   0.00086892 205.52619856  -1.534
## Smoking                     -0.00020482   0.00020087 251.04702321  -1.020
## Diabetes                    -0.00114251   0.00043049 269.11682409  -2.654
## No.Physical.Activity         0.00031890   0.00017291 237.73388083   1.844
## Obesity                      0.00025257   0.00014003 307.96857100   1.804
## Poor.Sleeping.Habits         0.00024011   0.00013482 297.27089752   1.781
## Poor.Mental.Health          -0.00015941   0.00045070 103.52749015  -0.354
##                             Pr(>|t|)    
## (Intercept)                  0.00379 ** 
## Affluence                  0.0000529 ***
## Singletons.in.Tract          0.27814    
## Seniors.in.Tract             0.78006    
## African.Americans.in.Tract   0.02508 *  
## Noncitizens.in.Tract         0.00574 ** 
## High.BP                      0.84265    
## Binge.Drinking               0.01287 *  
## Cancer                       0.74536    
## Asthma                       0.11391    
## Heart.Disease                0.00623 ** 
## COPD                         0.12653    
## Smoking                      0.30887    
## Diabetes                     0.00843 ** 
## No.Physical.Activity         0.06638 .  
## Obesity                      0.07226 .  
## Poor.Sleeping.Habits         0.07595 .  
## Poor.Mental.Health           0.72429    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of fixed effects could have been required in summary()
## 
## Correlation of Fixed Effects:
##             (Intr) Afflnc Sng..T Snr..T A.A..T Nnc..T Hgh.BP Bng.Dr Cancer
## Affluence   -0.050                                                        
## Sngltns.n.T -0.056  0.043                                                 
## Snrs.n.Trct  0.395  0.293  0.073                                          
## Afrcn.Am..T  0.242  0.076 -0.405  0.202                                   
## Nnctzns.n.T -0.072  0.153  0.125  0.057 -0.190                            
## High.BP     -0.095  0.157  0.099  0.007 -0.234  0.327                     
## Bing.Drnkng -0.488 -0.040 -0.205 -0.068  0.042 -0.076  0.149              
## Cancer      -0.495 -0.095  0.231 -0.172 -0.074 -0.066 -0.329 -0.019       
## Asthma      -0.269 -0.096 -0.262 -0.121 -0.013  0.211  0.052  0.008 -0.157
## Heart.Dises -0.058  0.077 -0.301 -0.132  0.213 -0.054  0.000  0.034 -0.602
## COPD         0.479  0.010  0.128  0.172 -0.006  0.156  0.058  0.060 -0.212
## Smoking     -0.043  0.105 -0.119 -0.137 -0.105  0.159 -0.082 -0.327  0.157
## Diabetes     0.036 -0.301 -0.078 -0.133 -0.230 -0.253 -0.446  0.075  0.367
## N.Physcl.Ac -0.116  0.034  0.101  0.079  0.059 -0.274  0.004  0.126  0.336
## Obesity     -0.066  0.383  0.398  0.202  0.133  0.193 -0.103 -0.147  0.118
## Pr.Slpng.Hb -0.385 -0.351  0.162 -0.326 -0.321 -0.046 -0.156  0.087  0.028
## Pr.Mntl.Hlt -0.354  0.183 -0.008  0.022  0.051 -0.165  0.028  0.130  0.417
##             Asthma Hrt.Ds COPD   Smokng Diabts N.Ph.A Obesty Pr.S.H
## Affluence                                                          
## Sngltns.n.T                                                        
## Snrs.n.Trct                                                        
## Afrcn.Am..T                                                        
## Nnctzns.n.T                                                        
## High.BP                                                            
## Bing.Drnkng                                                        
## Cancer                                                             
## Asthma                                                             
## Heart.Dises  0.336                                                 
## COPD        -0.322 -0.491                                          
## Smoking      0.144  0.083 -0.476                                   
## Diabetes    -0.106 -0.432 -0.008  0.278                            
## N.Physcl.Ac -0.023 -0.360  0.087 -0.274 -0.169                     
## Obesity     -0.126 -0.021  0.091 -0.220 -0.376 -0.045              
## Pr.Slpng.Hb  0.000  0.239 -0.093 -0.167 -0.060 -0.153 -0.115       
## Pr.Mntl.Hlt -0.437 -0.066 -0.389 -0.028  0.071 -0.086  0.025 -0.081

Testing Rate

testing.data.state <- compiled.stats[[length(daily_filenames)]][, c("Province_State", "Testing_Rate")]
testing.data.state <- testing.data.state[!is.na(testing.data.state$Testing_Rate),]
testing.data.state <- testing.data.state[order(testing.data.state$Testing_Rate),]

col.state <- rep("pink", nrow(testing.data.state))

avg.test.rate <- mean(testing.data.state$Testing_Rate, na.rm = T)

col.state[testing.data.state$Testing_Rate < avg.test.rate] <- "grey"
col.state[testing.data.state$Province_State == "Oklahoma"] <- "lightblue"

par(mar = c(5,6,4,2))
barplot(testing.data.state$Testing_Rate, names.arg = testing.data.state$Province_State, horiz = T, main = "Testing Rate by State", las = 2, cex.axis = 1, cex.names = 0.5, col = col.state, border = F, xlab = "Total number of people tested per 100,000 persons.")
abline(v = avg.test.rate, col = "red")
text(x = avg.test.rate + 10, y = 1, labels = "Average Testing Rate", adj = c(0, 0.5), col = "red")

Pink highlights the last 14 days.

day.first.case <- min(which(US.total$cases.total > 100))
n.days <- nrow(US.total)

twoweek.col <- c(rep("grey", n.days-day.first.case-13), rep("pink", 14))

par(mar = c(5,5,4,2))
barplot(US.total$cases.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Total COVID-19 cases by Date in US", 
        las = 2, cex.axis = 1, cex.names = 0.5,
        col = twoweek.col, border = F)

barplot(US.total$cases.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Total COVID-19 cases by Date in US, log scale", 
        las = 2, cex.axis = 1, cex.names = 0.5, log = "y",
        col = twoweek.col, border = F)

barplot(US.total$deaths.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Total COVID-19 deaths by Date in US", 
        las = 2, cex.axis = 1, cex.names = 0.5,
        col = twoweek.col, border = F)

barplot(US.total$deaths.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Total COVID-19 deaths by Date in US, log scale", 
        las = 2, cex.axis = 1, cex.names = 0.5, log = "y",
        col = twoweek.col, border = F)

barplot(US.total$rise.cases.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Rise in Cases of COVID-19 by Date in US", 
        las = 2, cex.axis = 1, cex.names = 0.5,
        col = twoweek.col, border = F)

barplot(US.total$rise.deaths.total[day.first.case:n.days], 
        names = US.total$day[day.first.case:n.days],
        main = "Rise in Deaths of COVID-19 by Date in US", 
        las = 2, cex.axis = 1, cex.names = 0.5,
        col = twoweek.col, border = F)